#include "Compare.h"
#include "IVisitor.h"

Compare::Compare(const exprTypePtr& left, const IntList_& ops, const ExprTypeList& comparators, int nodeId):
    exprType(nodeId),
    _left(left),
    _ops(ops),
    _comparators(comparators)
{
}
    
Compare::~Compare()
{
    _comparators.clear();
}
    
QString Compare::type() const
{
    return "Compare";
}
    

exprTypePtr Compare::left()
{
    return _left;
}

void Compare::setLeft(const exprTypePtr& left)
{
    _left = left;
}

IntList_ Compare::ops()
{
    return _ops;
}

void Compare::setOps(const IntList_& ops)
{
    _ops = ops;
}

ExprTypeList Compare::comparators()
{
    return _comparators;
}

void Compare::setComparators(const ExprTypeList& comparators)
{
    _comparators = comparators;
}

    
QString Compare::toString() const
{
    return QString("Compare[left=%1, ops=%2, comparators=%3]").
                arg(_left ? _left->toString():"").
                arg(_ops).
                arg(_comparators.toString());
}
    
void Compare::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitCompare(node.dynamicCast<Compare>());
}
    
void Compare::traverse(IVisitor* visitor)
{
    if (_left != NULL)
        _left->accept(visitor, _left);
    _comparators.traverse(visitor);
}